package sgi.message;

import sgi.client.SGIUserAccountMenuController;
import sgi.details_new.ImageDetails;
import sgi.user.User;

/**sets queries required for purchasing samples*/
public class MessagePurchaseSample extends Message {

	private String qGetBalance;
	private String qSetBalance;
	private String qCheckAlreadyPurchasedSample;
	private String qCheckAlreadyPurchasedImage;
	private boolean purcahseComplete;
	private boolean insufficiantBalance;
	private boolean SampleAlreadyPurchased;
	private boolean ImageAlreadyPurchased;
	private User user;
	private int imageid;
	private ImageDetails details;
	private float price;
	private float tariff;
	private byte[] blobAsBytes;
	
	/**Constructor. Recieves imageID and sets the queries for modifying balance, checking for subscriptions and if sample/image were already purchased*/
	public MessagePurchaseSample(int imageid) {
		super("select image from tariff where pending = 1");
		this.imageid = imageid; 
		user = SGIUserAccountMenuController.getUser();
		setqGetBalance("select balance from customers where username = '"+user.getUsername()+"'");
		setqCheckAlreadyPurchasedImage("select COUNT(*) from user_images where username = '" + user.getUsername() + "' and imageid = " + imageid + " and image = 1");
		setqCheckAlreadyPurchasedSample("select COUNT(*) from user_images where username = '" + user.getUsername() + "' and imageid = " + imageid + " and sample = 1");
	}

	public String getqGetBalance() {
		return qGetBalance;
	}

	public void setqGetBalance(String qGetBalance) {
		this.qGetBalance = qGetBalance;
	}

	public String getqSetBalance() {
		return qSetBalance;
	}

	public void setqSetBalance(String qSetBalance) {
		this.qSetBalance = qSetBalance;
	}


	public float getPrice() {
		return price;
	}

	public void setPrice(float d) {
		this.price = d;
	}

	public float getTariff() {
		return tariff;
	}

	public void setTariff(float f) {
		this.tariff = f;
	}

	public boolean isPurcahseComplete() {
		return purcahseComplete;
	}

	public void setPurcahseComplete(boolean purcahseComplete) {
		this.purcahseComplete = purcahseComplete;
	}
	
	public String getUsername()
	{
		return user.getUsername();
	}

	public int getImageid() {
		return imageid;
	}

	public void setSampleid(int Sampleid) {
		this.imageid = Sampleid;
	}

	public String getqCheckAlreadyPurchasedSample() {
		return qCheckAlreadyPurchasedSample;
	}

	public void setqCheckAlreadyPurchasedSample(
			String qCheckAlreadyPurchasedSample) {
		this.qCheckAlreadyPurchasedSample = qCheckAlreadyPurchasedSample;
	}

	public boolean isInsufficiantBalance() {
		return insufficiantBalance;
	}

	public void setInsufficiantBalance(boolean insufficiantBalance) {
		this.insufficiantBalance = insufficiantBalance;
	}

	public boolean isSampleAlreadyPurchased() {
		return SampleAlreadyPurchased;
	}

	public void setSampleAlreadyPurchased(boolean SampleAlreadyPurchased) {
		this.SampleAlreadyPurchased = SampleAlreadyPurchased;
	}

	public byte[] getBlobAsBytes() {
		return blobAsBytes;
	}

	public void setBlobAsBytes(byte[] blobAsBytes) {
		this.blobAsBytes = blobAsBytes;
	}

	public String getqCheckAlreadyPurchasedImage() {
		return qCheckAlreadyPurchasedImage;
	}

	public void setqCheckAlreadyPurchasedImage(
			String qCheckAlreadyPurchasedImage) {
		this.qCheckAlreadyPurchasedImage = qCheckAlreadyPurchasedImage;
	}

	public boolean isImageAlreadyPurchased() {
		return ImageAlreadyPurchased;
	}

	public void setImageAlreadyPurchased(boolean imageAlreadyPurchased) {
		ImageAlreadyPurchased = imageAlreadyPurchased;
	}

	public ImageDetails getDetails() {
		return details;
	}

	public void setDetails(ImageDetails details) {
		this.details = details;
	}
	
}
